#!/bin/bash

mark() {
	sed -n -e 's/\([^ ]\)  *\([^ ]\)/\1 \2/
	s/^ *$//
	s/^ *\([^ ]\)/\1/
	s/\([^ ]\) *$/\1/
	s|\*\([^\* ]*\)\*|<em>\1</em>|g
	p' |sed -n -f "marksed"  
}

fin="/dev/stdin"
fout="/dev/stdout"
while getopts ":i:o:" a 
do 
	case "$a" in
		i)
			fin="$OPTARG"
			;;
		o)
			fout="$OPTARG"
			;;
	esac
done
if [[ $fin == '-' ]] ; then
	fin='/dev/stdin'	
fi
if [[ $fout == '-' ]]; then
	fout='/dev/stdout'

fi
cat "$fin" | mark > "$fout"



